<?php
/**
 * Profile.php
 *
 * 系统全局状态数据对象模型类.
 *
 * This source file is subject to the new BSD license that is bundled
 * with this package in the file LICENSE.txt.
 * It is also available through the world-wide-web at this URL:
 * http://momoger.com/license
 *
 * @category	Momoger
 * @package 	Momoger_Model
 * @author 		Leo
 * @version    	1.0
 * @copyright  	Copyright © 2009 www.momoger.com All Rights Reserved.
 * @license    	http://momoger.com/license     New BSD License
 */

/** Momoger_Model_Abstract */
//require_once 'Abstract.php';

/**
 * 系统全局状态数据对象模型类.
 *
 * @category 	Momoger
 * @package		Momoger_Model
 * @copyright  	Copyright © 2009 www.momoger.com All Rights Reserved.
 * @license    	http://momoger.com/license     New BSD License
 */
class Momoger_Model_Profile extends Momoger_Model_Abstract {

	//系统注册用户总数
	const REGIST_USER_NUMBER = 'registed_user_number';

	//系统上传图片总数
	const TOTAL_PHOTO_NUMBER = 'total_photo_number';

	//系统日志发表总数
	const TOTAL_ARTICLE_NUMBER = 'total_article_number';

	/**
	 * 构造函数.
	 *
	 * @param mixed $options 快速设置参数.
	 */
	public function __construct($options = null) {
        parent::__construct($options);
	}

    /**
     * 获取某个系统状态值
     *
     * @param string $key 系统状态名
     * @return string
     */
    public function getProfile($key) {
		return $this->find($key)->getAll();
    }

    /**
     * 获取所有系统状态信息
     *
     * @return array
     */
    public function getProfiles() {
    	$profiles = $this->findAll();
    	$data = array();
    	if (count($profiles)) {
    		foreach ($profiles as $profile) {
    			array_push($data, $profile->getAll());
    		}
    	}
    	return $data;
    }

    /**
     * 获取数据地图对象.
     *
     * @return Momoger_Model_Mapper_Profile
     */
    protected function getMapper() {
        if (null === $this->_mapper) {
            $this->setMapper(new Momoger_Model_Mapper_Profile());
        }
        return $this->_mapper;
    }
}